import { Vec2 } from "./Math2d"

enum EInputEventType {
    MOUSE_EVENT,
    MOUSE_DOWN,
    MOUSE_UP,
    MOUSE_MOVE,
    MOUSE_DRAG,

    KEYBOARD_EVENT,
    KEY_DOWN,
    KEY_UP,
    KEY_PRESS
}

enum EMouseButton {
    LEFT,
    MIDDLE,
    RIGHT,
}

class CanvasInputEvent{
    altKey:boolean
    ctrlKey:boolean
    shiftKey:boolean
    type:EInputEventType
    constructor(
        altKey:boolean = false,
        ctrlKey:boolean = false,
        shiftKey:boolean = false,
        type:EInputEventType = EInputEventType.MOUSE_EVENT
    ){
        this.altKey = altKey
        this.ctrlKey = ctrlKey
        this.shiftKey = shiftKey
        this.type = type
    }
}
class CanvasMouseEvent extends CanvasInputEvent{
    button:EMouseButton = EMouseButton.LEFT
    canvasPosition:Vec2
    localPosition:Vec2

    constructor(
        canvasPos:Vec2,
        buton:EMouseButton,
        altKey:boolean = false,
        ctrlKey:boolean = false,
        shiftKey:boolean = false,
    ){
        super(altKey,ctrlKey,shiftKey)
        this.button = buton;
        this.canvasPosition = canvasPos
        this.localPosition = Vec2.create()
    }
}
class CanvasKeyBoardEvent extends  CanvasInputEvent{
    key:string
    keyCode:number

    repeat:boolean

    constructor(
        key:string,
        keyCode:number,
        repeat:boolean,
        altKey:boolean = false,
        ctrlKey:boolean = false,
        shiftKey:boolean = false,
    ){
        super(altKey,ctrlKey,shiftKey)
        this.key = key;
        this.keyCode = keyCode
        this.repeat = repeat
    }
}

export {
    CanvasMouseEvent,
    CanvasKeyBoardEvent
}